#!/bin/bash
#author merci

HOST="localhost"
USER="root"
PASS="你的mysql密码"
DBNAME="要备份的库名"
BACKPATH="/data/back"
D=$(date +%Y%m%d)

if [ ! -f "my.cnf" ]
then
	touch my.cnf
	cat >> my.cnf << EOF
[client]
host=${HOST}
user=${USER}
password='${PASS}'
EOF
fi

mkdir -p ${BACKPATH}/$D
mysqldump --defaults-extra-file=my.cnf ${DBNAME} > ${BACKPATH}/$D/${DBNAME}.sql
